class code1 {
    //相同就删除，栈->数组模拟
    public String removeDuplicates(String s) {
        //模拟栈
        StringBuffer ret = new StringBuffer();
        char[] ss = s.toCharArray();
        for(char ch:ss) {
            //相同就删
            if(ret.length()>0 && ch==ret.charAt(ret.length()-1)) ret.deleteCharAt(ret.length()-1);
                //不同就直接加入
            else ret.append(ch);
        }
        return ret.toString();
    }
}